#include"Thread.hpp"
#include<vector>
using namespace ThreadMoudle;
void print(const std::string& name)
{
    int cnt = 0;
    while(1){
        sleep(1);
        std::cout << name << " is running,cnt:" << cnt << std::endl;
        cnt++;
    }
}
// int main()
// {
//     Thread t("thread-1",print);
//     t.start();
//     sleep(5);
// }

//多线程创建
std::vector<Thread> Threads;
int main()
{
    for (int i = 0; i < 10;i++)
    {
        Thread t("thread-" + std::to_string(i), print);
        Threads.push_back(t);
    }

    sleep(10);
    for (auto &t : Threads)
    {
        t.start();
    }

    sleep(10);
    for (auto &t : Threads)
    {
        t.stop();
    }

    sleep(10);
    for(auto& t:Threads)
    {
        t.join();
    }
}